package com.storage.web.controller.system;

import com.storage.common.annotation.Log;
import com.storage.common.core.controller.BaseController;
import com.storage.common.core.domain.AjaxResult;
import com.storage.common.core.domain.ServiceResponse;
import com.storage.common.core.page.TableDataInfo;
import com.storage.common.enums.BusinessType;
import com.storage.framework.util.ShiroUtils;
import com.storage.system.domain.StorageIndustry;
import com.storage.system.service.IStorageIndustryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 行业类型 Controller
 *
 * @author hzhang7
 * @date 2019-10-31
 */
@Api(tags = "行业类型相关接口")
@RestController
public class StorageIndustryController extends BaseController {

    @Autowired
    private IStorageIndustryService storageIndustryService;

    /**
     * 分页查询行业类型列表
     */
    @ApiOperation(value = "分页查询行业类型列表")
    @GetMapping("/system/industry/list")
    @ResponseBody
    public TableDataInfo list(StorageIndustry storageIndustry, Integer pageNum, Integer pageSize) {
        ServiceResponse<TableDataInfo> response = storageIndustryService.selectStorageIndustryList(storageIndustry, pageNum, pageSize);
        return response.getData();
    }
    /**
     * 新增/编辑 保存行业类型
     */
    @ApiOperation(value = "新增/编辑 保存行业类型")
    @Log(title = "新增/编辑 保存行业类型", businessType = BusinessType.INSERT)
    @PostMapping("/system/industry/save")
    @ResponseBody
    public AjaxResult save(@RequestBody StorageIndustry storageIndustry) {
        storageIndustry.setCreateUserId(ShiroUtils.getUserId());
        ServiceResponse<StorageIndustry> response = storageIndustryService.updateStorageIndustry(storageIndustry);
        return AjaxResult.success(response.getData());
    }

    /**
     * 删除行业类型
     */
    @ApiOperation(value = "删除行业类型")
    @Log(title = "行业类型", businessType = BusinessType.DELETE)
    @GetMapping("/system/industry/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        return toAjax(storageIndustryService.deleteStorageIndustryByIds(ids));
    }
}
